<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <title>
            <?php echo $title ?>-<?php echo C('STIE_NAME') ?>
        </title>
        <link rel="stylesheet" href="//at.alicdn.com/t/font_aw93q7mhbm7k3xr.css">
        <link rel="stylesheet" href="/php/aas/Public/layui/css/layui.css">
        <link rel="stylesheet" href="/php/aas/Public/css/global.css">
        <script src="/php/aas/Public/layui/layui.js"></script>
    </head>
    
    <body>
        <div class="header">
            <div class="main">
                <a class="logo" href="/php/aas" title="Fly">  
                <!-- 线上路径改为  /php/aas/ -->
                    Fly社区
                </a>
                <div class="nav">
                    <a href="<?php echo U('home/jie/all');?>">
                        <i class="iconfont icon-wenda">
                        </i>
                        讨论
                    </a>
                    <a href="/case/2017/">
                        <i class="iconfont icon-iconmingxinganli" style="top: 2px;">
                        </i>
                        案例
                    </a>
                    <a href="http://www.layui.com/">
                        <i class="iconfont icon-ui">
                        </i>
                        框架
                    </a>
                </div>

                <?php if(isset($_SESSION['id'])){ ?>
                    <div class="nav-user">
                        <a class="avatar" href="<?php echo U('home/set/index');?>">
                            <img src="/php/aas/<?php echo $_SESSION['face'] ?>">
                            <cite>
                                <?php echo $_SESSION['nickname'] ?>
                            </cite>
                        </a>
                        <div class="nav">
                            <a href="<?php echo U('home/set/index');?>">
                                <i class="iconfont icon-shezhi">
                                </i>
                                设置
                            </a>
                            <a href="<?php echo U('home/login/loginout');?>">
                                <i class="iconfont icon-tuichu" style="top: 0; font-size: 22px;">
                                </i>
                                退了
                            </a>
                        </div>
                    </div>
                <?php }else{ ?>

                    <div class="nav-user">
                        <a class="unlogin" href="/user/login/">
                            <i class="iconfont icon-touxiang">
                            </i>
                        </a>
                        <span>
                            <a href="<?php echo U('home/login/index');?>">
                                登入
                            </a>
                            <a href="<?php echo U('home/reg/index');?>">
                                注册
                            </a>
                        </span>
                        <p class="out-login">
                            <a href="<?php echo U('home/login/qqlogin');?>"
                            class="iconfont icon-qq" title="QQ登入">
                            </a>
                            <a href="http://fly.layui.com:8098/app/weibo/" onclick="layer.msg('正在通过微博登入', {icon:16, shade: 0.1, time:0})"
                            class="iconfont icon-weibo" title="微博登入">
                            </a>
                        </p>
                    </div>

                <?php } ?>

            </div>
        </div>
	<div class="main layui-clear">
    <div class="wrap">
        <div class="content detail">
            <div class="fly-panel detail-box">
                <h1>
                    <?php echo $question['title'] ?>
                </h1>
                <div class="fly-tip fly-detail-hint">
                    <span <?php if( $question['status']=='已采纳'){ echo "class='fly-tip-jie'";} ?>><?php echo $question['status'] ?></span>  
                    <div class="jie-admin-box" data-id="8770">
                    </div>
                    <div class="fly-list-hint">
                        <a href="#comment">
                            <i class="iconfont" title="回答">
                                
                            </i>
                            <?php echo $question['answer_num'] ?>
                        </a>
                        <i class="iconfont" title="人气">
                            
                        </i>
                        <?php echo $question['view_num'] ?>
                    </div>
                </div>
                <div class="detail-about">
                    <a class="jie-user" href="<?php echo U('home/u/index',array('id'=>$question['uid']));?>">
                        <img src="/php/aas/<?php echo $question['face'] ?>"
                        alt=" <?php echo $question['nickname'] ?>">
                        <cite>
                            <?php echo $question['nickname'] ?>
                            <em>
                                发布于<?php echo CT($question['create_time']) ?>
                            </em>
                        </cite>
                    </a>
                    <div class="detail-hits" id="LAY_jieAdmin" data-id="8770">
                        <span style="color:#FF7200">
                            悬赏：<?php echo $question['kiss_num'] ?>飞吻
                        </span>
                        <?php if($question['id']==$store['qid'] && $_SESSION['id']==$store['uid']){ ?>
                       <span class="layui-btn layui-btn-mini jie-admin  layui-btn-danger" type="collect" data-type="add"
                       qid='<?php echo $question['id']; ?>' id="unc" >取消收藏</span>
                        <?php }else{ ?> 
                         <span class="layui-btn layui-btn-mini jie-admin " type="collect" data-type="add" qid='<?php echo $question['id']; ?>'  id='collect'>
                        收藏
                        </span> 
                        <?php } ?> 
                    </div>
                </div>
                <div class="detail-body photos">
                    <?php echo htmlspecialchars_decode($question['content']) ?>
                </div>
            </div>
            <div class="fly-panel detail-box" style="padding-top: 0;">
                <ul class="jieda photos" id="jieda">
                    <?php if(empty($answers)){ ?>
                        <li class="fly-none">
                            没有任何回答
                        </li>
                    <?php }else{ ?>
                        <?php foreach ($answers as $row) { ?>
                            <li data-id="30429">
                                <a name="item-1491000319505">
                                </a>
                                <div class="detail-about detail-about-reply">
                                    <a class="jie-user" href="<?php echo U('home/u/index',array('id'=>$row['uid']));?>">
                                        <img src="/php/aas/<?php echo $row['face'] ?>"
                                        alt=" <?php echo $row['nickname'] ?>" layer-index="2">
                                        <cite>
                                            <i>
                                                <?php echo $row['nickname'] ?>
                                            </i>
                                        </cite>
                                    </a>
                                    <div class="detail-hits">
                                        <span>
                                            <?php echo CT($row['create_time']) ?>
                                        </span>
                                    </div>
                                    <?php if($row['status']==1){ ?>
                                    <i class="iconfont icon-caina" title="最佳答案"></i>
                                    <?php }else{ ?>
                                   
                                    <?php } ?>   
                                </div>
                                <div class="detail-body jieda-body">
                                    <?php echo htmlspecialchars_decode($row['content']) ?>
                                </div>
                                <div class="jieda-reply">
                                    <span class="jieda-zan" type="zan">
                                        <i class="iconfont icon-zan">
                                        </i>
                                        <em>
                                           <?php echo $row['zan_num'] ?>
                                        </em>
                                    </span>
                                    <span type="reply">
                                        <i class="iconfont icon-svgmoban53">
                                        </i>
                                        回复
                                    </span>

                                    <?php if (isset($_SESSION['id'])) { ?>
                                         <?php if($row['status']==0 && $question['uid']==$_SESSION['id'] && $row['uid']!=$_SESSION['id'] &&$question['status']=='未结帖'){ ?>
                                                <span class="jieda-accept" type="accept" qid='<?php echo $question['id']; ?>' aid='<?php echo $row['id']; ?>';>采纳</span>
                                        <?php }else{ ?>
                                   
                                        <?php } ?>

                                    <?php }else{ ?>
                                        <span>Hi!</span>
                                    <?php } ?>


                                </div>
                            </li>
                        <?php } ?>
                    <?php } ?>
                </ul>
                <div class="layui-form layui-form-pane">
                    <form action="" method="post">
                        <div class="layui-form-item layui-form-text">
                            <a name="comment">
                            </a>
                            <div class="layui-input-block">
                                
                                <textarea id="L_content" name="content" required="" lay-verify=""
                                placeholder="我要回答" class="layui-textarea fly-editor" style="height: 150px;"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <input type="hidden" name="qid" value="<?php echo $question['id'] ?>">
                            <button class="layui-btn" lay-filter="add" lay-submit="">
                                提交回答
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div class="edge">
        <dl class="fly-panel fly-list-one">
            <dt class="fly-panel-title">
                最近热帖
            </dt>
            <?php foreach ($hotView as $row) { ?>
                <dd>
                    <a href="<?php echo U('home/jie/index',array('id'=>$row['id']));?>">
                        <?php echo $row['title'] ?>
                    </a>
                    <span>
                        <i class="iconfont">
                            
                        </i>
                        <?php echo $row['view_num'] ?>
                    </span>
                </dd>
            <?php } ?>
        </dl>
        <dl class="fly-panel fly-list-one">
            <dt class="fly-panel-title">
                最近热议
            </dt>
            <?php foreach ($hotAnsewr as $row) { ?>
                <dd>
                    <a href="<?php echo U('home/jie/index',array('id'=>$row['id']));?>">
                        <?php echo $row['title'] ?>
                    </a>
                    <span>
                        <i class="iconfont"></i>
                        <?php echo $row['answer_num'] ?>
                    </span>
                </dd>
            <?php } ?>
        </dl>
    </div>
</div>
<script type="text/javascript">
    layui.use(['form','jquery','layedit',], function(){
        var form = layui.form()
        ,layer = layui.layer,
        $= layui.jquery;
        layedit = layui.layedit;
 
        layedit.set({
          uploadImage: {
            url: '<?php echo U('home/jie/uploadImage');?>' //接口url
            ,type: '' //默认post
          }
        });
        index = layedit.build('L_content', {
          height: 180 //设置编辑器高度
        });


        //监听提交    
      form.on('submit(add)', function(data){

        content = layedit.getContent(index);

        if(content.length<20){
           layer.msg("内容不低于20", function(){}
                );
           return false;
        }
        // console.log(data);
        // 
        data.field.content = content;

        $.ajax({
            url: '<?php echo U('home/jie/addAnswer');?>',
            type: 'POST',
            dataType: 'json',
            data: data.field,
        })
        .done(function(respones) {
            if(respones.error==1){
                layer.msg(respones.info, function(){}
                );
            }else{
                layer.alert(respones.info, {icon: 6},function  () {
                    location.reload();
                });
            }
        })
        .fail(function() {
            console.log("error");
        })
        
        
        return false;
      });
  
  
});

</script>

<!-- 收藏 -->
<script type="text/javascript">
    layui.use(['jquery'], function(){
        
        layer = layui.layer,
        $= layui.jquery;

        $("#collect").click(function  () {
            qid= $(this).attr('qid');
        
        $.ajax({
            url: '<?php echo U('home/jie/storeAdd');?>',
            type: 'POST',
            dataType: 'json',
            data:{qid:qid},
        })
        .done(function(respones) {
            if(respones.error==1){
                layer.msg(respones.info, function(){}
                );
            }else{
                layer.alert(respones.info, {icon: 6},function  () {
                      location.reload();
                });
            }
        })
        .fail(function() {
            console.log("error");
        })
        
        return false;
      });
  
});
</script>


<!-- //取消收藏 -->
<script type="text/javascript">
    layui.use(['jquery'], function(){
        
        layer = layui.layer,
        $= layui.jquery;

        $("#unc").click(function  () {
        
        qid= $(this).attr('qid');
        
        $.ajax({
            url: '<?php echo U('home/jie/storeDel');?>',
            type: 'POST',
            dataType: 'json',
            data:{qid:qid},
            //需要追加的数据
        })
        .done(function(respones) {
            if(respones.error==1){
                layer.msg(respones.info, function(){}
                );
            }else{
                layer.alert(respones.info, {icon: 6},function  () {
                      location.reload();
                });
            }
        })
        .fail(function() {
            console.log("error");
        })
        
        return false;
      });
  
});
</script>

<!-- 采纳 -->
<script type="text/javascript">
    layui.use(['jquery'], function(){
        
        layer = layui.layer,
        $= layui.jquery;

        $(".jieda-accept").click(function  () {

        aid= $(this).attr('aid');
        qid= $(this).attr('qid');

        $.ajax({
            url: '<?php echo U('home/jie/accept');?>',
            type: 'POST',
            dataType: 'json',
            data:{aid:aid,qid:qid},
            //需要追加的数据
        })
        .done(function(respones) {
            if(respones.error==1){
                layer.msg(respones.info, function(){}
                );
            }else{
                layer.alert(respones.info, {icon: 6},function  () {
                      location.reload();
                });
            }
        })
        .fail(function() {
            console.log("error");
        })
        
        return false;
      });
    
});
</script>

<!-- 点赞 -->
<script type="text/javascript">

        $(".jieda-zan").click(function  () {

        aid= $(this).attr('aid');
        qid= $(this).attr('qid');

      //   $.ajax({
      //       url: '<?php echo U('home/jie/zan');?>',
      //       type: 'POST',
      //       dataType: 'json',
      //       data:{aid:aid},
      //       //需要追加的数据
      //   })
      //   .done(function() {
      //       if(respones.error==1){
      //           console.log("success");
      //           );
      //       }else{
      //           layer.alert( () {
      //             console.log("error");
      //           });
      //       }
      //   })
      //   .fail(function() {
      //       console.log("error");
      //   })

      //   return false;
      // });
    
});
</script>
<div class="footer">
            <p>
                <a href="http://fly.layui.com/">
                    Fly社区
                </a>
                2017 &copy;
                <a href="http://www.layui.com/">
                    layui.com
                </a>
            </p>
            <p>
                <a href="http://fly.layui.com/jie/3147.html" target="_blank">
                    产品授权
                </a>
                <a href="http://fly.layui.com/jie/8157.html" target="_blank">
                    获取Fly社区模版
                </a>
                <a href="http://fly.layui.com/jie/2461.html" target="_blank">
                    微信公众号
                </a>
            </p>
        </div>
    </body>

</html>